package com.baipiao.permission.backend.entity.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @author Livi Luo
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(description = "响应对象带数据")
public class ResData<T> extends Res {

    @Schema(description = "数据对象")
    private T data;

    public static <T> ResData<T> success(T data) {
        return success(ResStatusEnum.success, data);
    }

    public static <T> ResData<T> success(ResStatusEnum status, T data) {
        ResData<T> res = new ResData<>();
        res.setStatus(true);
        res.setCode(status.getCode());
        res.setMsg(status.getMsg());
        res.setData(data);
        return res;
    }

}
